/*
 *    Copyright (c) 2018-2025, cloud All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: cloud
 */

package com.fuyao.cloud.asset.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fuyao.cloud.asset.util.AssetUtils;
import com.fuyao.cloud.common.core.model.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

/**
 * 采购申请清单
 *
 * @author 时间的朋友
 * @date 2021-11-22 13:58:57
 */
@Data
@TableName("fy_asset_purchaseapply_list")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "采购申请清单")
public class AssetPurchaseapplyList extends BaseEntity<AssetPurchaseapplyList> {

    private static final long serialVersionUID = 1L;

    /**
     * 状态：默认为0{0：草稿、1：处理中、2：已审批、3：已完成、4：作废}状态值根据父单的更新，已完成状态根据单项入库数量等于采购数量并且验收单完成后更新为已完成
     */
    @ApiModelProperty(value="状态：默认为0{0：草稿、1：处理中、2：已审批、3：已完成、4：作废}状态值根据父单的更新，已完成状态根据单项入库数量等于采购数量并且验收单完成后更新为已完成 ")
    private String status;

    /**
     * 所属单据的ID
     */
    @ApiModelProperty(value="所属单据的ID")
    private Long parentId;

    /**
     * 所属单据名称
     */
    @ApiModelProperty(value="所属单据名称")
    private String parentCaseid;


    /**
     * 批次号
     */
    @ApiModelProperty(value="批次号")
    private String batchnumber;

    /**
     * 资产分类全编码
     */
    @ApiModelProperty(value="资产分类全编码")
    private String classifiedCode;

    /**
     * 资产分类全名称
     */
    @ApiModelProperty(value="资产分类全名称")
    private String classified;

    /**
     * 资产分类名称
     */
    @ApiModelProperty(value="资产分类名称")
    private String ctiName;

    /**
     * 资产分类ID
     */
    @ApiModelProperty(value="资产分类ID")
    private Long ctiId;

    /**
     * 照片
     */
    @ApiModelProperty(value="照片")
    private String photo;

    /**
     * 条形码
     */
    @ApiModelProperty(value="条形码")
    private String barcode;

    /**
     * 名称
     */
    @ApiModelProperty(value="名称")
    private String name;

    /**
     * 规格型号
     */
    @ApiModelProperty(value="规格型号")
    private String model;

    /**
     * 计量单位
     */
    @ApiModelProperty(value="计量单位")
    private String unit;

    /**
     * 采购数量
     */
    @ApiModelProperty(value="采购数量")
    private Long quantity;

    /**
     * 单价
     */
    @ApiModelProperty(value="单价")
    private BigDecimal price;

    /**
     * 预计费用
     */
    @ApiModelProperty(value="预计费用")
    private BigDecimal amount;

    @TableField(exist = false)
    private Long amountLong;

    /**
     * 备注
     */
    @ApiModelProperty(value="备注")
    private String remarks;

    /**
     * 已采购数量
     */
    @ApiModelProperty(value="已采购数量")
    private Long purchasedQuantity;

    /**
     * 已到货数量
     */
    @ApiModelProperty(value="已到货数量")
    private Long arrivedQuantity;

    /**
     * 已发放数量
     */
    @ApiModelProperty(value="已发放数量")
    private Long grantQuantity;

	@ApiModelProperty(value="资产信息ID")
    private Long sauId;

	/**
	 * 资产编码
	 */
	@ApiModelProperty(value="资产编码")
	private String number;

	public String getStatusCn(){
		return AssetUtils.formatStatus(String.valueOf(this.status));
	}

	public Long getAmountLong() {
		return this.amount.longValue();
	}

	public BigDecimal getAmountSum() {
		return amount.multiply(new BigDecimal(quantity));
	}
}
